package com.huan.maket;

import com.huan.bean.ChannelPromotionCount;
import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.streaming.api.functions.windowing.WindowFunction;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.flink.util.Collector;

import java.sql.Timestamp;

//通过键控（分组）窗口评估的功能的基本接口
public class AppMarketingStatisticsResult implements WindowFunction<Long, ChannelPromotionCount, Tuple, TimeWindow> {




    @Override
    public void apply(Tuple tuple, TimeWindow window, Iterable<Long> input, Collector<ChannelPromotionCount> out) throws Exception {
        String windowEnd = new Timestamp( window.getEnd() ).toString();
        Long count = input.iterator().next();

        out.collect(new ChannelPromotionCount("total","total",windowEnd,count) );
    }
}
